#include <iostream>
#include <unistd.h>
#include <signal.h>

using namespace std;

//void handler(int signo) {
//    cout << "get a signo : " << signo << endl;
//   
//    while (true) {
//        sleep(1);
//    }
//    
//    exit(10);
//}

void handler(int signo) {
    cout << "father process... " << getpid() << " " << getppid() << " signo : " << signo << endl;
}


int main() {
  

    signal(SIGCLD, handler);

    if (fork() == 0) {
        int count = 5;
        while (count--) {
            cout << "child process... " << getpid() << " " << getppid() << " count : " << count << endl;
            sleep(1);
        }
        cout << "child process quit" << endl;
        exit(10);
    }

    sleep(10);



    //struct sigaction act, oact;
    //act.sa_flags = 0;
    //act.sa_handler = handler;
    //sigemptyset(&act.sa_mask);
//  //  act.sa_restorer = NULL;
//  //  act.sa_sigaction = NULL;


    //sigaddset(&act.sa_mask, 3);
    //sigaction(2, &act, &oact);
    //while (1) {
    //    cout << "process is running ... " << endl; 
    //    sleep(1);
    //}

    return 0;
}
